package com.cat.controller;


import com.cat.dao.EmployeeDao;
import com.cat.entities.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;
import java.util.Collection;
import java.util.Map;

@Controller
@RequestMapping("/user")
public class LoginController {
    @Autowired
    EmployeeDao employeeDao;

    @RequestMapping("/login")
    public String loginValidate(@RequestParam("username") String username, @RequestParam("password") String password, Map<String,Object>params, HttpSession session){
        System.out.println(username+":username+"+"password"+password);
        if(!StringUtils.isEmpty(username) && password.equals("123456")){
            session.setAttribute("username",username);
            return "redirect:/main.html";
        }else{
            params.put("msg","用户名密码错误！请重新输入！");
            return "index";
        }
    }

}
